package com.jrx.anytxn.param.enums;

import com.jrx.anytxn.common.data.TxnRespCode;
import com.jrx.anytxn.common.exception.TxnRuntimeException;

public enum BizTypeEnum {

    /**
     * 兴安花
     */
    BIZ_TYPE_XAH("1",true,"兴安花"),
    /**
     * 兴安付
     */
    BIZ_TYPE_XAF("2",false,"兴安付"),
    /**
     * 信用就医
     */
    BIZ_TYPE_XYJY("3",false,"信用就医"),
    /**
     * 兴安借
     */
    BIZ_TYPE_XAJ("4",false,"兴安借");

    public static BizTypeEnum getByCode(String code){
        for (BizTypeEnum bizTypeEnum: values()) {
            if (bizTypeEnum.getCode().equals(code)){
                return bizTypeEnum;
            }
        }
        return null;
    }

    public static BizTypeEnum getByCodeWhenNullException(String code){
        for (BizTypeEnum bizTypeEnum: values()) {
            if (bizTypeEnum.getCode().equals(code)){
                return bizTypeEnum;
            }
        }
        throw new TxnRuntimeException(TxnRespCode.NO_DATA.getCode(),code+"对应的枚举值不存在");
    }

    private String code;
    /**
     * 是否支持账单分期 true 支持 否则不支持
     */
    private boolean canStaging;
    private String msg;

    BizTypeEnum(String code, boolean canStaging, String msg) {
        this.code = code;
        this.canStaging = canStaging;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public boolean getCanStaging() {
        return canStaging;
    }
}
